class ConversationModel {
  int? id;
  int cid;
  String title;
  String icon;
  int? updateAt;
  int stickTime;
  int? messageCount;
  String? lastMessage;

  // 时候有新消息
  bool hasChanged = false;
  // 构造函数
  ConversationModel({
    this.id,
    required this.cid,
    required this.title,
    required this.icon,
     this.updateAt,
    required this.stickTime,
     this.messageCount,
     this.lastMessage,
  });

  // 从 JSON 数据创建对象实例
  factory ConversationModel.fromJson(Map<String, dynamic> json) {
    return ConversationModel(
      id: json['id'] as int,
      cid: json['cid'] as int,
      title: json['title'] as String,
      icon: json['icon'] as String,
      updateAt: json['updateAt'] as int,
      stickTime: json['stickTime'] as int,
      messageCount: json['messageCount'] as int,
      lastMessage: json['lastMessage'] as String,
    );
  }

  // 将对象实例转换为 JSON 数据
  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'cid': cid,
      'title': title,
      'icon': icon,
      'updateAt': updateAt,
      'stickTime': stickTime,
      'messageCount': messageCount,
      'lastMessage': lastMessage,
    };
  }
}